var ClubInputWindowType = {
    CreateClub: 1,
    ChangeRemarks: 2,
    InputID: 3,
};

var ClubInputWindow = Window.extend({
    _ccsFileName: res.ClubInputWindow_json,

    _callBack: null,
    _tipsContent: '',
    _editBox: null,
    _inputMax: 6,
    initWindow: function (tipsContent, type, callBack, inputMax) {
        this._callBack = callBack;
        this._tipsContent = tipsContent;
        this._nodeList['lb_content'].setVisible(false);
        this._inputMax = inputMax || this._inputMax;

        this._initTitle(type);
        this._createEditBox();
    },

    _initClickListeners: function () {
        this._clickListeners = {
            'btn_ok': '_cliclBtnOk',
        }
    },

    _initTitle: function (type) {
        this._nodeList['titleCreateClub'].setVisible(false);
        this._nodeList['titleChangeRemarks'].setVisible(false);
        this._nodeList['titleInputID'].setVisible(false);
        if (type == ClubInputWindowType.CreateClub) {
            this._nodeList['titleCreateClub'].setVisible(true);
        } else if (type == ClubInputWindowType.ChangeRemarks) {
            this._nodeList['titleChangeRemarks'].setVisible(true);
        } else {
            this._nodeList['titleInputID'].setVisible(true);
        }
    },

    _createEditBox: function () {
        this._editBox = new cc.EditBox(cc.size(230, 30), new cc.Scale9Sprite(res.transparent113));
        this._nodeList['input_bg'].getParent().addChild(this._editBox);
        this._editBox.setName('searchTxt');
        this._editBox.setPosition(this._nodeList['input_bg'].getPosition());
        this._editBox.setFontColor(cc.color('#0D437E'));
        this._editBox.setPlaceholderFontColor(cc.color(13, 67, 126));
        this._editBox.setDelegate(this);
        this._editBox.setMaxLength(this._inputMax);
        this._editBox.setFontSize(26);
        this._editBox.setPlaceholderFontSize(26);
        this._editBox.setPlaceHolder(this._tipsContent);
    },
    _cliclBtnOk: function () {
        var input = this._editBox.getString();
        if (input.length == 0) {
            showToast('请输入内容');
            return;
        }
        if (this._callBack) {
            this._callBack(input);
        }
        this.close();
    },


    editBoxEditingDidBegin: function (editBox) {
        this._editBox.setPlaceHolder('')
    },
    editBoxEditingDidEnd: function (editBox) {
        var input = this._editBox.getString();
        if (input.length == 0) {
            this._editBox.setPlaceHolder(this._tipsContent);
        }
    },
    editBoxTextChanged: function (editBox, text) {
    },
    editBoxReturn: function (editBox) {
    }
});